package com.javabi.codegenerator.java.model.executable;

import com.javabi.codegenerator.model.object.executable.ModelExecutableSerializer;
import com.javabi.codeobject.java.type.IJavaType;

public class JavaModelExecutableSerializer {

	private final ModelExecutableSerializer serializer;
	private volatile IJavaType interfaceType;
	private volatile IJavaType type;

	public JavaModelExecutableSerializer(ModelExecutableSerializer serializer) {
		if (serializer == null) {
			throw new NullPointerException("serializer");
		}
		this.serializer = serializer;
	}

	public ModelExecutableSerializer get() {
		return serializer;
	}

	public String getName() {
		return serializer.getName();
	}

	public IJavaType getType() {
		if (type == null) {
			throw new NullPointerException("type");
		}
		return type;
	}

	public void setTypes(IJavaType type, IJavaType interfaceType) {
		if (type == null) {
			throw new NullPointerException("type");
		}
		if (interfaceType == null) {
			throw new NullPointerException("interfaceType");
		}
		this.type = type;
		this.interfaceType = interfaceType;
	}

	public IJavaType getInterfaceType() {
		return interfaceType;
	}

}
